package com.lagou.service.impI;

import com.lagou.dao.AccountDao;
import com.lagou.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author wsl
 * @Date 2021/11/14 20:22
 * @Project_Name jdbc_spring
 */
@Service
@Transactional //事务注解
public class AccountServiceImpI implements AccountService {

    @Autowired
    private AccountDao accountDao;

    //事务注解
    //@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.REPEATABLE_READ,readOnly = false,timeout = -1)
    public void transfer(String outUser, String inUser, Double money) {

        //调用dao层的in及out方法
        accountDao.out(outUser,money);

        //测试异常事务的方法
        int i = 1/0;

        accountDao.in(inUser, money);
    }
}
